#include "burst.h"

Burst::Burst(stdBurst std, Point p)
{
	_std = std;
	_std.bitmap.p = p;
	_reMove = false;
	alpha = 0;
	srand((unsigned)time(NULL)*10);
	_angle = rand()%360;
	_angle = angleToRad(_angle);
	nowdraw = rand()%4;
}

void Burst::updata()
{
	alpha += 0.05;
	check();
}

void Burst::check()
{
	if (alpha > 1)
	{
		_reMove = true;
	}
}

void Burst::draw()
{
	al_draw_tinted_rotated_bitmap(_std.bitmap.bitmap[nowdraw],
		al_map_rgba_f(alpha, alpha, alpha, alpha), _std.bitmap.w, _std.bitmap.h,
		_std.bitmap.p.x, _std.bitmap.p.y, _angle, 0);
	al_draw_tinted_rotated_bitmap(_std.bitmap.bitmap[nowdraw],
		al_map_rgba_f(alpha, alpha, alpha, alpha), _std.bitmap.w, _std.bitmap.h,
		_std.bitmap.p.x, _std.bitmap.p.y, _angle + ALLEGRO_PI/6, 0);
	al_draw_tinted_rotated_bitmap(_std.bitmap.bitmap[nowdraw],
		al_map_rgba_f(alpha, alpha, alpha, alpha), _std.bitmap.w, _std.bitmap.h,
		_std.bitmap.p.x, _std.bitmap.p.y, _angle + ALLEGRO_PI/3, 0);
}

bool Burst::checkRemove()
{
	//cout << _reMove;
	return _reMove;
}